package hiho.ku._1066;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	
	private static final Map<String, String> father = new HashMap<String, String>();

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		for (int i = 0; i < n; i++) {
			int op = in.nextInt();
			String nameOne = in.next();
			String nameTwo = in.next();
			String fatherOne = getFather(nameOne);
			String fatherTwo = getFather(nameTwo);
			if (op == 1)
				System.out.println((fatherOne.equals(fatherTwo))? "yes" : "no");
			else
				father.put(fatherOne, fatherTwo);
		}
	}
	
	private static String getFather(String me) {
		if (!father.containsKey(me)) {
			father.put(me, me);
			return me;
		}
		if (!me.equals(father.get(me)))
			father.put(me, getFather(father.get(me)));
		return father.get(me);
	}

}
